import allure

from basepage.BasePage import BasePage


class LoginPage(BasePage):

    def __init__(self, page):
        super().__init__(page)
        self.账号 = '账号'
        self.密码 = '密码'
        self.登录 = ("button", "登 录")
    def login(self,username,password):
        with allure.step('打开登录页面'):
            self.goto('/verification/login?redirect=%2Findex')
        with allure.step("输入手机号"):
            self.input_text_get_by_placeholder(self.账号,text=username)
        with allure.step("输入验证码"):
            self.input_text_get_by_placeholder(self.密码, text=password)
            self.page.wait_for_timeout(5000)
        with allure.step('点击登录'):
            self.click_get_by_role(self.登录)
        with allure.step('断言'):
            self.expect_assert(self.page.get_by_role("menubar").get_by_role("link", name="首页")).to_be_visible()
